package edu.zut.servlet;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * http://localhost:8080/Web203_204/showInfo   get
 * url属于请求的一部分，所以url的解析需要使用到request对象
 */
public class ShowInfoServlet extends HttpServlet {

    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        //解析当前url请求
        String uri = request.getRequestURI();
        System.out.println("uri = " + uri);
        StringBuffer url = request.getRequestURL();
        System.out.println("url = " + url);
        //获取请求的上下文路劲
        String contextPath = request.getContextPath();
        System.out.println("contextPath = " + contextPath);
        //获取请求资源路劲
        String servletPath = request.getServletPath();
        System.out.println("servletPath = " + servletPath);
        //获取请求资源的路劲信息
        String pathInfo = request.getPathInfo();
        System.out.println("pathInfo = " + pathInfo);
        //获取请求的方式
        String method = request.getMethod();
        System.out.println("method = " + method);

    }
}
